'''
Created on Oct 9, 2011

@author: solagna
'''

import urllib2
import BeautifulSoup.BeautifulSoup
import WikiParser.ParseCommon

class webPage(object):
    '''
    classdocs
    '''
    __PageBody__ = ""

    def __init__(self,urlToGet):
        '''
        The constructor downloads the web page.
        '''
        pagelink = urllib2.urlopen(urlToGet)
        self.__PageBody__ = pagelink.read()
        pagelink.close()
    
    def getBody (self):
        return self.__PageBody__
    
        
    def printPage(self):
        print self.__PageBody__
    
    def returnTableX (self,x): 
        soup = BeautifulSoup.BeautifulSoup.BeautifulSoup(self.__PageBody__)
        #firstTable = WikiParser.ParseCommon.findTableX(soup, 1)
        return WikiParser.ParseCommon.parseTableX(soup, x, True)
        
if __name__ == "__main__":
    #Download all.
    x = webPage("https://wiki.egi.eu/wiki/Top-BDII_list_for_NGI")
    #x.printPage()
    print x.returnTableX(2)